﻿using System;
using System.Threading.Tasks;
using System.Web.Http;
using Ewk.MachineLearning.Persistance.DataAccess;
using Ewk.MachineLearning.Persistance.Domain;

namespace Clustering.MultidimensionalScaling.Web.UI.Controllers
{
    public abstract class TextEntityController<T> : EntityController<T>
        where T : TextEntity, new()
    {
        // GET api/textentity/5/content
        [HttpGet, ActionName("Content")]
        public async Task<string> ContentAsync(Guid id)
        {
            return await Task.Factory.StartNew(() =>
            {
                using (var catalog = CatalogFactory.NewCatalog())
                {
                    var repository = new TextEntityRepository<T>(catalog);
                    return repository.GetContentById(id);
                }
            });
        }
    }
}
